import E from "wangeditor";
import Vue from "vue";
Vue.use({
  install() {
    Vue.component("wang-editor", {
      props: {},
      data() {
        return {
          editor: null
        };
      },
      mounted() {},
      methods: {
        init() {
          const dom = this.$refs.editor;
          if (dom && !this.editor) {
            this.editor = new E(this.$refs.editor);
            this.editor.customConfig.uploadImgServer =
              "/api/index/upload?comefrom=wangeditor";
            this.editor.customConfig.uploadFileName = "file";
            this.editor.create();
          } else
            setTimeout(() => {
              this.init();
            }, 20);
        }
      },
      render: h => {
        return h("div", {
          ref: "editor",
          style: {
            textAlign: "left"
          }
        });
      }
    });
  }
});
